package com.esl.coordinator.command;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.esl.coordinator.exception.STiTEQATMELIntegrationException;

/**
 * @author jeffreychang Abstract base class for all Commands
 */
public abstract class Command {
	static final Logger LOG = LoggerFactory.getLogger(Command.class);

	private boolean isCommandSent = false;
	private int retryCount = 1;
	private int threadSleepTime = 0;

	private CommandReceiver commandClient; // receiver object [command pattern]
	int expectedResponseBytes;
	private String[] commandResponse;

	public Command(CommandReceiver commandClient, int expectedResponseBytes) {
		this.commandClient = commandClient;
		this.expectedResponseBytes = expectedResponseBytes;
	}

	abstract public String[] buildCommand()
			throws STiTEQATMELIntegrationException;

	abstract public boolean isCommandSuccessful();

	public CommandReceiver getCommandClient() {
		return commandClient;
	}

	public void setCommandClient(CommandReceiver commandClient) {
		this.commandClient = commandClient;
	}

	public boolean isCommandSent() {
		return isCommandSent;
	}

	public void setCommandSent(boolean isCommandSent) {
		this.isCommandSent = isCommandSent;
	}

	public int getRetryCount() {
		return retryCount;
	}

	public void setRetryCount(int retryCount) {
		this.retryCount = retryCount;
	}

	public int getThreadSleepTime() {
		return threadSleepTime;
	}

	public void setThreadSleepTime(int threadSleepTime) {
		this.threadSleepTime = threadSleepTime;
	}

	public int getExpectedResponseBytes() {
		return expectedResponseBytes;
	}

	public void setExpectedResponseBytes(int expectedResponseBytes) {
		this.expectedResponseBytes = expectedResponseBytes;
	}

	public String[] getCommandResponse() {
		return commandResponse;
	}

	public void setCommandResponse(String[] commandResponse) {
		this.commandResponse = commandResponse;
	}

}
